package exercise2_4;

import static org.junit.Assert.assertEquals;
import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

public class exercise2_4_test {

	Student regularMasterStudent;
	Student intMasterStudent;
	
	@Before
	public void setUp() throws Exception {
		
		regularMasterStudent = new RegularMasterStudent();
		regularMasterStudent.setName("john Smith");
		regularMasterStudent.setAge(12);
		regularMasterStudent.setSemester(3);
		
		intMasterStudent = new InternationalMasterStudent();
		intMasterStudent.setName("john Doe");
		intMasterStudent.setAge(12);
		intMasterStudent.setSemester(3);
		
	}

	@Test
	public void testRegularMaster() {
		double actualGrade = 3.5;
		((RegularMasterStudent) regularMasterStudent).setBachelorGrade(actualGrade);
		Assert.assertEquals(((RegularMasterStudent) regularMasterStudent).getBachelorGrade(), actualGrade);
	}
	
	@Test
	public void testInternationalMaster(){
		String home = "Italy";
		((InternationalMasterStudent) intMasterStudent).setHomeCountry(home);
		assertEquals(((InternationalMasterStudent) intMasterStudent).getHomeCountry(), home);
	}
	
	@Test(expected=ClassCastException.class)
	public void testRegularCasting(){
		((InternationalStudent)regularMasterStudent).getHomeCountry();
	}
	
	@Test(expected=ClassCastException.class)
	public void testInternationalCasting(){
		((RegularStudent)intMasterStudent).getHomeCity();
	}

}
